#ifndef MOCHA_DETAIL_EXPORTED_OBJECT_HPP_INCLUDED
#define MOCHA_DETAIL_EXPORTED_OBJECT_HPP_INCLUDED

/**
 * @file
 */

#include <cstdint>
#include "mocha/detail/self_call.hpp" // Included here for convenience.
#include "mocha/interface_language.hpp"
#include "mocha/plugin.hpp"

namespace mocha {
/**
 * Base for exported (adapted) objects.
 * @param P 
 * @param I 
 * @param C 
 * @param X 
 */
template<typename P, typename I, typename C, typename X>
class exported_object {
public:
	/// 
	typedef P plugin_type;
	/// 
	typedef I interface_type;
	/// 
	typedef C c_interface_type;
	/// 
	typedef X cpp_interface_type;
	enum {
		/// 
		interface_language = mocha::interface_language<interface_type>::language
	};
	virtual ~exported_object() {}
	/**
	 * Provides C++ plugin writers with a default create function.
	 * Can be provided as part of a plugin object's register parameters.
	 * @param op 
	 * @return 
	 */
	static void* create(mocha_plugin_object_params* op) {
		return new plugin_type(op);
	}
	/**
	 * Provides C++ plugin writers with a default destroy function.
	 * Can be provided as part of a plugin object's register parameters.
	 * @param object 
	 * @return 
	 */
	static std::int32_t destroy(void* object) {
		if (!object) {
			return -1;
		}
		delete reinterpret_cast<plugin_type*>(object);
		return 0;
	}
};
}

#endif

